<template>
    <v-app id="inspire">
        <v-navigation-drawer
                v-model="drawer"
                app
                clipped
                class="showOrder"
        >
            <v-list dense>
                <v-list-item link href="/manager/article/list">
                    <v-list-item-action>
                        <v-icon>mdi-home</v-icon>
                    </v-list-item-action>
                    <v-list-item-content>
                        <v-list-item-title>文章管理</v-list-item-title>
                    </v-list-item-content>
                </v-list-item>
                <v-list-item link href="/manager/article/draft/list">
                    <v-list-item-action>
                        <v-icon>mdi-home</v-icon>
                    </v-list-item-action>
                    <v-list-item-content>
                        <v-list-item-title>草稿管理</v-list-item-title>
                    </v-list-item-content>
                </v-list-item>
                <v-list-item link @click="gotoCategoryPage">
                    <v-list-item-action>
                        <v-icon>mdi-email</v-icon>
                    </v-list-item-action>
                    <v-list-item-content>
                        <v-list-item-title>类别管理</v-list-item-title>
                    </v-list-item-content>
                </v-list-item>
                <v-list-item link @click="logout">
                    <v-list-item-action>
                        <v-icon>mdi-email</v-icon>
                    </v-list-item-action>
                    <v-list-item-content>
                        <v-list-item-title>退出</v-list-item-title>
                    </v-list-item-content>
                </v-list-item>
            </v-list>
        </v-navigation-drawer>

        <v-app-bar
                app
                color="indigo"
                dark
                clipped-left
                class="showOrder"
        >
            <v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon>
            <v-toolbar-title>Application</v-toolbar-title>
            <v-btn right absolute class="mr-5" href="/manager/article/create">
                写博客
            </v-btn>
        </v-app-bar>

        <v-main >

            <router-view></router-view>
        </v-main>
        <v-footer
                color="indigo"
                app
                class="showOrder"
        >
            <span class="white--text">&copy; {{ new Date().getFullYear() }}</span>
        </v-footer>
        <v-dialog
                class="showOrder"
                persistent
                v-model="this.$store.getters.getShowDialogStatus"
                max-width="290"
        >
            <LoginComponent></LoginComponent>
        </v-dialog>
    </v-app>
</template>

<script>
  import LoginComponent from '@/components/LoginComponent'

  export default {
    name: 'Admin',
    data(){
      return{
        drawer:null,
        show:true

      }
    },components:{
      LoginComponent
    },
    methods:{
      gotoCategoryPage(){
        this.$router.push("/manager/category");
      },
     async logout(){
      const{data:res}= await this.$http.post('/logout');
       // 删除在本地存储的token
       window.localStorage.removeItem("authToken");
       if (res.errorCode==200){
         this.$router.push("/");
       } else {
         alert("退出失败，请重试！")
       }
     }
    }
  }
</script>

<style scoped>

</style>